package inabit.expressioncompiler.productions;

import inabit.compiler.parser.grammar.NonTerminal;
import inabit.compiler.parser.grammar.Production;
import inabit.compiler.parser.grammar.Symbol;
import inabit.data.expression.arithmetic.NumberExpression;
import inabit.expressioncompiler.parser.ExpressionSemanticAction;

/**Z -> N*/
/**@author Rafael Rocha*/
public class Z_Rule2 extends Production{

	private NonTerminal N;
	public Z_Rule2() {
		super("Z");
	}

	@Override
	protected Symbol[] production(final NonTerminal nonTerminal) {
		N = new NonTerminal("N");
		Symbol[] symbols = {
			N,
			new ExpressionSemanticAction(nonTerminal) {
				public void execute() {
					nonTerminal.code = addArithmeticExpressionAndGetCode(
							new NumberExpression(Double.parseDouble(N.code)));
				}
			}
		};
		return symbols;
	}

}
